package org.sgx.gwteditors.client.impl1.basetypes;

import java.util.Date;

/**
 * a simple time datatype. Hours always go from 0 to 23. Provides tools fot conversion from/ between date. 
 * @author sg
 *
 */
public class Time {
Integer hour, minute, second;
public Time() {
	this(0,0,0); 
}
public Time(Integer hour, Integer minute, Integer second) {
	super();
	this.hour = hour;
	this.minute = minute;
	this.second = second;
}

public Integer getHour() {
	return hour;
}

public void setHour(Integer hour) {
	this.hour = hour;
}

public Integer getMinute() {
	return minute;
}

public void setMinute(Integer minute) {
	this.minute = minute;
}

public Integer getSecond() {
	return second;
}

public void setSecond(Integer second) {
	this.second = second;
}
/**
 * will return a Date wich is today with hor, minute and seconds changed to reflect this Time instance.
 * @return
 */
public Date toDate() {
	return flush(new Date());
}
public Time load(Date d) {
	setHour(d.getHours());
	setMinute(d.getMinutes()); 
	setSecond(d.getSeconds());
	return this;
}
public Date flush(Date d) {
	d.setHours(getHour()); 
	d.setMinutes(getMinute()); 
	d.setSeconds(d.getSeconds());
	return d;
}

}
